package app.species;

import sim.util.*;
import sim.engine.*;

public class StationaryFoodCreator extends EntityCreator{

	/**
	 * 
	 */
	private static final long serialVersionUID = 5466855549697135478L;

	public StationaryFoodCreator(int interval, SpawnPoint[] spoints){

		super(interval, spoints);

	}

	public void step(SimState state){

		super.step(state);

		if(this.timeSinceLastSpawn >= this.spawnInterval && this.spawnPoints.length > 0){

			SpeciesSim sim = (SpeciesSim)state;
			MutableDouble2D initPosition = this.spawnPoints[sim.random.nextInt(this.spawnPoints.length)].getRandomLocation(sim.random);

			StationaryFood newFood = new StationaryFood(initPosition, new MutableDouble2D(0, 0));

			sim.stationaryFood.setObjectLocation(newFood, new Double2D(initPosition));
			newFood.stoppable = sim.schedule.scheduleRepeating(newFood);

			this.timeSinceLastSpawn = 0;

		}

	}

}
